import { FeedBack } from '@/api/feedBack/server'
const state = {
    userInfo: JSON.parse(sessionStorage.getItem('userData'))

}

const mutations = {
    SET_USER_INFO(state, data) {
        state.userInfo = data
        sessionStorage.setItem('userData', JSON.stringify(data))
    }
}

const actions = {
    async getuserId({ commit }, val) {
        try {
            const result = await FeedBack.UserGetUserInfoAsync()
            if (result.success) {
                return new Promise(resolve => {
                    const userInfo = result.data
                    commit('SET_USER_INFO', userInfo)
                    resolve(val)
                })
            }
        } catch (err) {
            console.log(err)
        }
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
